/**
 * 代码生成接口
 */

import { Get, Post, Delete, Put, RequestParams, ResponseData } from '../common/decorator'

export default class GenService {

  /**
   * 查询生成表数据
   * @param res 
   * @returns 
   */
  @Get("/code/gen/list", { requestType: 'params' })
  listTable(res: any) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 不分页查询生成表数据
  @Get("/code/gen/listNoPage", { requestType: "params" })
  listTableNoPage(res: any) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 查询db数据库列表
  @Get("/code/gen/db/list", { requestType: 'params' })
  listDbTable(res: any) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 查询表详细信息
  @Get("/code/gen/${tableId}", { requestType: 'path' })
  getGenTable(res: { tableId: any }) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 修改代码生成信息
  @Put("/code/gen", { requestType: 'data' })
  updateGenTable(res: any) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }


  // 导入表
  @Post("/code/gen/importTable", { requestType: 'data' })
  importTable(res: any) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 预览生成代码
  @Get("/code/gen/preview/${tableId}", { requestType: "all" })
  previewTable(res: { path: { tableId: string }, params: { templateType } }) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 删除代码生成表
  @Delete("/code/gen/${tableId}")
  delTable(res: { tableId: string }) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 生成代码（自定义路径）
  @Get("/code/gen/genCode/${tableName}")
  genCode(res: { tableName: string }) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 同步数据库
  @Get("/code/gen/synchDb/${tableName}", { requestType: 'all' })
  synchDb(res: { path: { tableName: string }, params: { configId: string } }) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 更新或添加列数据
  @Put("/code/gen/saveOrUpdateGenColumn", { requestType: 'data' })
  saveOrUpdateGenColumn(res: any) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 删除列数据
  @Delete("/code/gen/removeColumns/${id}", { requestType: 'path' })
  removeColumns(res: { id: string }) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 根据传入的list，修改其排序
  @Post("/code/gen/updateColumnSort", { requestType: 'data' })
  updateColumnSort(res: any) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 根据tableId获取列列表
  @Get("/code/gen/column/${tableId}", { requestType: 'path' })
  columnListByTableId(res: { tableId: string }) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

  // 根据tableName生成菜单
  @Post("/code/gen/generateMenu/${tableName}", { requestType: 'all' })
  generateMenu(res: { path: { tableName: string }, params: { configId: string } }) {
    const convertedResult: unknown = res as unknown;
    return convertedResult as Promise<ResponseData>
  }

}